

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/broswer.jpg">
  <link rel="icon" href="/img/broswer.jpg">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Feng Zikai">
  <meta name="keywords" content="">
  
    <meta name="description" content="1. 系统安装1.1 选择发行版展示选择的发行版wsl –shutdown 1wsl --list --online  安装 建议安装Ubuntu,或者Arch 一个用的人多；一个软件新，社区活跃；Debian 日常使用软件包太老了 1wsl --install -d Ubuntu-22.04  1.2 修改安装位置 首先关闭运行的linux发行版 1wsl --shutdown  在D盘创建一个">
<meta property="og:type" content="article">
<meta property="og:title" content="解决wsl2使用遇到的问题">
<meta property="og:url" content="http://example.com/2022/05/08/%E8%A7%A3%E5%86%B3wsl2%E4%BD%BF%E7%94%A8%E9%81%87%E5%88%B0%E7%9A%84%E9%97%AE%E9%A2%98/index.html">
<meta property="og:site_name" content="F7kyyy的博客">
<meta property="og:description" content="1. 系统安装1.1 选择发行版展示选择的发行版wsl –shutdown 1wsl --list --online  安装 建议安装Ubuntu,或者Arch 一个用的人多；一个软件新，社区活跃；Debian 日常使用软件包太老了 1wsl --install -d Ubuntu-22.04  1.2 修改安装位置 首先关闭运行的linux发行版 1wsl --shutdown  在D盘创建一个">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/img/article/wsl.png">
<meta property="article:published_time" content="2022-05-08T08:19:33.000Z">
<meta property="article:modified_time" content="2023-07-09T13:47:12.000Z">
<meta property="article:author" content="Feng Zikai">
<meta property="article:tag" content="环境配置">
<meta property="article:tag" content="wsl">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="http://example.com/img/article/wsl.png">
  
  
  
  <title>解决wsl2使用遇到的问题 - F7kyyy的博客</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":60,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading1.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>F7kyyy&#39;s blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/links/">
                <i class="iconfont icon-link-fill"></i>
                <span>友链</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="解决wsl2使用遇到的问题"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-05-08 16:19" pubdate>
          2022年5月8日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          3.2k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          27 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">解决wsl2使用遇到的问题</h1>
            
            
              <div class="markdown-body">
                
                <h2 id="1-系统安装"><a href="#1-系统安装" class="headerlink" title="1. 系统安装"></a>1. 系统安装</h2><h3 id="1-1-选择发行版"><a href="#1-1-选择发行版" class="headerlink" title="1.1 选择发行版"></a>1.1 选择发行版</h3><p>展示选择的发行版wsl –shutdown</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">wsl <span class="hljs-literal">--list</span> <span class="hljs-literal">--online</span><br></code></pre></td></tr></table></figure>

<p>安装</p>
<p>建议安装Ubuntu,或者Arch 一个用的人多；一个软件新，社区活跃；Debian 日常使用软件包太老了</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">wsl <span class="hljs-literal">--install</span> <span class="hljs-literal">-d</span> Ubuntu<span class="hljs-literal">-22</span>.<span class="hljs-number">04</span><br></code></pre></td></tr></table></figure>

<h3 id="1-2-修改安装位置"><a href="#1-2-修改安装位置" class="headerlink" title="1.2 修改安装位置"></a>1.2 修改安装位置</h3><ul>
<li><p>首先关闭运行的linux发行版</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">wsl <span class="hljs-literal">--shutdown</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>在D盘创建一个目录用来存放新的WSL，比如我创建了一个<code>D:\Environment\UbuntuWSL</code>，导出它的备份</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">wsl <span class="hljs-literal">--export</span> Ubuntu<span class="hljs-literal">-22</span>.<span class="hljs-number">04</span> D:\Environment\UbuntuWSL\Ubuntu.tar<br></code></pre></td></tr></table></figure>

<img src="https://raw.githubusercontent.com/F7kyyy/picture/main/img/202305261819078.png" srcset="/img/loading1.gif" lazyload alt="image-20230526181905016" style="zoom:67%;" />
</li>
<li><p>注销原有的发行版</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">wsl <span class="hljs-literal">--unregister</span> Ubuntu<span class="hljs-literal">-22</span>.<span class="hljs-number">04</span><br></code></pre></td></tr></table></figure>

<p>正常卸载也是这么卸载，再注销之后直接在开始菜单搜索安装的发行版名字点击卸载就可以从磁盘中删除了</p>
</li>
<li><p>备份文件回复到新的子系统中，可以重命名</p>
<p><code>import 发行版名称 新的磁盘位置 导出压缩包位置</code> </p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">wsl <span class="hljs-literal">--import</span> Ubuntu D:\Environment\UbuntuWSL D:\Environment\UbuntuWSL\Ubuntu.tar<br></code></pre></td></tr></table></figure>

<img src="https://raw.githubusercontent.com/F7kyyy/picture/main/img/202305261824929.png" srcset="/img/loading1.gif" lazyload alt="image-20230526182410865" style="zoom: 67%;" />
</li>
<li><p>恢复默认用户<code>f7kyyy</code></p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">Ubuntu2204 config <span class="hljs-literal">--default-user</span> f7kyyy<br></code></pre></td></tr></table></figure>

<p>这里应该是纯英文或者纯数字，如果名字叫做<code>Ubuntu-22.04</code>就改为 <code>Ubuntu2204</code></p>
<p><strong>不知道为什么，我在使用Ubuntu的时候，powershell 提示找不到命令，始终未解决。</strong></p>
<p>建议前往<a target="_blank" rel="noopener" href="https://learn.microsoft.com/zh-cn/windows/wsl/install-manual">网站</a>，手动下载发行版，然后将后缀改为<code>zip</code>,在想要安装的位置解压，然后双击<code>.exe</code>文件手动安装。</p>
</li>
</ul>
<h2 id="2-更新系统提示"><a href="#2-更新系统提示" class="headerlink" title="2. 更新系统提示"></a>2. 更新系统提示</h2><h3 id="2-1-安装cuda前"><a href="#2-1-安装cuda前" class="headerlink" title="2.1 安装cuda前"></a>2.1 安装cuda前</h3><p>你会发现没有这个文件夹</p>
<p><code>/usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link</code></p>
<p>解决方法：</p>
<ol>
<li><p>从<code>C:\Windows\System32\lxss\lib</code> 删除<code>libcuda.so</code> and <code>libcuda.so.1</code> </p>
</li>
<li><p>以管理员打开powershell，输入<code>wsl</code>,进入wsl环境,执行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">sudo <span class="hljs-built_in">ln</span> -sr /mnt/c/Windows/System32/lxss/lib/libcuda.so.1.1 /mnt/c/Windows/System32/lxss/lib/libcuda.so.1<br>sudo <span class="hljs-built_in">ln</span> -sr /mnt/c/Windows/System32/lxss/lib/libcuda.so.1.1 /mnt/c/Windows/System32/lxss/lib/libcuda.so<br></code></pre></td></tr></table></figure></li>
</ol>
<h3 id="2-2-安装cuda后"><a href="#2-2-安装cuda后" class="headerlink" title="2.2 安装cuda后"></a>2.2 安装cuda后</h3><p>不同的系统安装位置不一样，一般来说会安装在<code>/usr/local/cuda/</code>文件夹下，但是我使用的是arch linux，使用pacman 直接安装会安装在<code>/opt/cuda</code>文件夹中</p>
<p>使用以下命令建立软连接</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">sudo <span class="hljs-built_in">ln</span> -s /usr/lib/wsl/lib/libcuda.so.1 /opt/cuda/lib64/libcuda.so<br></code></pre></td></tr></table></figure>

<h2 id="3-系统代理"><a href="#3-系统代理" class="headerlink" title="3. 系统代理"></a>3. 系统代理</h2><h3 id="3-1-系统代理"><a href="#3-1-系统代理" class="headerlink" title="3.1  系统代理"></a>3.1  系统代理</h3><p>wsl1没有独立的IP,可以直接给<code>127.0.0.1:port</code>，进行代理</p>
<p>更新wsl2后，需要使用正则获取IP地址</p>
<p>在.<code>bashrc</code>,<code>.zshrc</code>中加上</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># &gt;&gt;&gt; setproxy &gt;&gt;&gt;</span><br><span class="hljs-built_in">export</span> hostip=$(<span class="hljs-built_in">cat</span> /etc/resolv.conf |grep -oP <span class="hljs-string">&#x27;(?&lt;=nameserver\ ).*&#x27;</span>)<br><span class="hljs-built_in">alias</span> setproxy=<span class="hljs-string">&#x27;export https_proxy=&quot;http://$&#123;hostip&#125;:10811&quot;;export http_proxy=&quot;http://$&#123;hostip&#125;:10811&quot;;&#x27;</span><br><span class="hljs-built_in">alias</span> unsetproxy=<span class="hljs-string">&#x27;unset all_proxy&#x27;</span><br><span class="hljs-comment"># &lt;&lt;&lt; setproxy &lt;&lt;&lt;</span><br></code></pre></td></tr></table></figure>

<p>config.fish</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 设置代理</span><br><span class="hljs-keyword">function</span> unsetproxy<br>    <span class="hljs-built_in">set</span> -e ALL_PROXY<br>end<br><br><span class="hljs-keyword">function</span> setproxy<br>    <span class="hljs-built_in">set</span> hostip $(<span class="hljs-built_in">cat</span> /etc/resolv.conf |grep -oP <span class="hljs-string">&#x27;(?&lt;=nameserver\ ).*&#x27;</span>)<br>    <span class="hljs-built_in">set</span> -xg ALL_PROXY http://<span class="hljs-variable">$hostip</span>:10811<br>end<br></code></pre></td></tr></table></figure>

<p>注意端口，在windows代理软件中打开<code>allow LAN</code>，或者<code>允许局域网代理</code></p>
<p><em>测试</em>：</p>
<p>执行<code>setproxy</code>后，<code>curl google.com</code>,返回html文件</p>
<p><img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture@main/img/202205081643996.png" srcset="/img/loading1.gif" lazyload alt="image-20220508164357859"></p>
<h3 id="3-2-为git设置代理"><a href="#3-2-为git设置代理" class="headerlink" title="3.2 为git设置代理"></a>3.2 为git设置代理</h3><p>写一个简单的python 脚本<code>setgitproxy.py</code>，为git设置代理</p>
<p>先使用pip安装<code>IPy</code></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-comment"># coding=utf-8</span><br><br><span class="hljs-keyword">import</span> socket<br><span class="hljs-keyword">import</span> fcntl<br><span class="hljs-keyword">import</span> struct<br><span class="hljs-keyword">import</span> os<br><span class="hljs-keyword">from</span> IPy <span class="hljs-keyword">import</span> IP<br><br><span class="hljs-comment"># 本地代理端口，你的和我不一定一样，按照自己的设置改动一下</span><br>PORT = <span class="hljs-number">10811</span><br><br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">get_ip_address</span>(<span class="hljs-params">ifname</span>):<br>    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)<br>    <span class="hljs-keyword">return</span> socket.inet_ntoa(fcntl.ioctl(<br>        s.fileno(),<br>        <span class="hljs-number">0x8915</span>,  <span class="hljs-comment"># SIOCGIFADDR</span><br>        struct.pack((<span class="hljs-string">&#x27;256s&#x27;</span>).encode(<span class="hljs-string">&quot;utf-8&quot;</span>), (ifname[:<span class="hljs-number">15</span>]).encode(<span class="hljs-string">&quot;utf-8&quot;</span>))<br>    )[<span class="hljs-number">20</span>:<span class="hljs-number">24</span>])<br><br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">get_windows_ip</span>(<span class="hljs-params">wsl_ip</span>):<br>    ip = IP(wsl_ip).make_net(<span class="hljs-string">&quot;20&quot;</span>).strNormal()<br>    ip = ip.split(<span class="hljs-string">&#x27;/&#x27;</span>)[<span class="hljs-number">0</span>][:-<span class="hljs-number">1</span>] + <span class="hljs-string">&#x27;1&#x27;</span><br>    <span class="hljs-keyword">return</span> ip<br><br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">config_git_proxy</span>(<span class="hljs-params">ip</span>):<br>    config_str = (<br>        <span class="hljs-string">&quot;git config --global https.proxy &#x27;https://%s:%d&#x27;&quot;</span> % (ip, PORT))<br>    <span class="hljs-comment"># print(config_str)</span><br>    ret = os.system(config_str)<br>    <span class="hljs-keyword">if</span> ret:<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;set git porxy fail&quot;</span>)<br>        <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">else</span>:<br>        config_str = (<br>            <span class="hljs-string">&quot;git config --global http.proxy &#x27;http://%s:%d&#x27;&quot;</span> % (ip, PORT))<br>        <span class="hljs-comment"># print(config_str)</span><br>        ret = os.system(config_str)<br>    <span class="hljs-keyword">if</span> ret:<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;set git porxy fail&quot;</span>)<br>        <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">else</span>:<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;set git porxy success&quot;</span>)<br>        <span class="hljs-keyword">return</span><br><br><br><span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&quot;__main__&quot;</span>:<br>    wsl_ip = get_ip_address(<span class="hljs-string">&#x27;eth0&#x27;</span>)<br>    windows_ip = get_windows_ip(wsl_ip)<br>    <span class="hljs-comment"># print(windows_ip)</span><br>    config_git_proxy(windows_ip)<br><br></code></pre></td></tr></table></figure>

<p>使用git 命令或者其他git GUI客户端前，执行<code>python setgitproxy.py</code>为git添加代理</p>
<p><img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture@main/img/202205081641462.png" srcset="/img/loading1.gif" lazyload alt="image-20220508164137335"></p>
<p><strong>最新更新，Clash Tun 模式使用全局代理解决一切问题</strong></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" class="category-chain-item">环境配置</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" class="print-no-link">#环境配置</a>
      
        <a href="/tags/wsl/" class="print-no-link">#wsl</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>解决wsl2使用遇到的问题</div>
      <div>http://example.com/2022/05/08/解决wsl2使用遇到的问题/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Feng Zikai</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年5月8日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/06/27/vscode%20%E9%85%8D%E7%BD%AEmsvc%E7%BC%96%E8%AF%91%E5%99%A8-%E4%BD%BF%E7%94%A8vcpkg%E8%BF%9B%E8%A1%8CC++%E5%8C%85%E7%AE%A1%E7%90%86/" title="vscode 配置msvc编译器 使用vcpkg进行C++包管理">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">vscode 配置msvc编译器 使用vcpkg进行C++包管理</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/04/19/heroku%E9%85%8D%E7%BD%AEv2ray/" title="heroku配置v2ray">
                        <span class="hidden-mobile">heroku配置v2ray</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <div style="font-size: 0.85rem"> <span id="timeDate">载入天数...</span> <span id="times">载入时分秒...</span> <script src="/js/duration.js"></script> </div> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>




  
<script src="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<script src="//cdn.jsdelivr.net/gh/metowolf/Metingjs@1.2/dist/Meting.min.js"></script>
<script src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
